package com.example.filesystem.repository;

import com.example.filesystem.model.FileInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface FileInfoRepository extends JpaRepository<FileInfo, Long> {
    List<FileInfo> findByUserId(Long userId);

    @Query("SELECT f FROM FileInfo f WHERE f.id = :id and f.userId =:userId")
    FileInfo find(Long id, Long userId);

    @Query("SELECT f FROM FileInfo f WHERE f.id = :id")
    FileInfo findByFileId(Long id);
}